package com.ea.common.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * @author NAME-L
 * @Description 系统设置枚举类
 * @className SysCfgKeyEnums
 * @date 2022-12-07 21:42:40
 */
public enum SysCfgKeyEnums {
    // 0:否
    // 1：是

    IS_OPEN_ORDER_FORM_REFERENCE_RULE("isOpenOrderFormReferenceRule","是否开启自定义订单编号生成规则" , 1 , "0" , 0),

    ORDER_FORM_REFERENCE_RULE_USER_DEFINED("orderFormReferenceRuleDefined" , "自定义订单编号生成规则" , 1 , "S" , 1),

    ORDER_FORM_REFERENCE_RULE_DEFAULT("orderFormReferenceRuleDefault" , "默认订单编号生成规则" , 1 , "S" , 1),

    IS_OPEN_GOODS_GENERATE_RULE("isOpenGoodsGenerateRule","是否开启货品编号生成规则" , 1 , "0" , 0),

    GOODS_GENERATE_NUM_RULE_PREFIX("goodsGenerateNumRulePrefix","货品编号生成规则固定前缀" , 1 , "" , 1),

    MODIFY_SKU_BARCODE_SAME_TIME("modifySkuBarcodeSameTime", "规格编号前缀是否追加货品编号", 1, "0" , 0),

    ALLOW_NEGATIVE_INVENTORY("allowNegativeInventory","是否允许货品负库存出库" , 1 , "0" , 0),

    LOGISTIC_LOCATION("logisticLocation", "发货地点", 1 , ""  ,2),



    ;

    private final String cfgKey;

    private final String cfgDesc;

    /**
     * 是否需要程序运行时进行初始化判断
     * 0：不需要；1：需要
     */
    private final Integer needInit;

    private  String defaultValue;

    private  Integer cfgType;

    SysCfgKeyEnums(String cfgKey, String cfgDesc, Integer needInit ) {
        this.cfgKey = cfgKey;
        this.cfgDesc = cfgDesc;
        this.needInit = needInit;
    }

    SysCfgKeyEnums(String cfgKey, String cfgDesc, Integer needInit , String defaultValue , Integer cfgType) {
        this.cfgKey = cfgKey;
        this.cfgDesc = cfgDesc;
        this.needInit = needInit;
        this.defaultValue = defaultValue;
        this.cfgType = cfgType;
    }

    public String getCfgKey() {
        return cfgKey;
    }

    public String getCfgDesc() {
        return cfgDesc;
    }

    public Integer getNeedInit() {
        return needInit;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public Integer getCfgType() {
        return cfgType;
    }

    public static List<String> initCfgKeyList() {
        List<String> cfgKeyList = new ArrayList<>();
        for (SysCfgKeyEnums enums : values()) {
            if (enums.getNeedInit().equals(YesOrNoEnum.YES.getCode())) {
                cfgKeyList.add(enums.getCfgKey());
            }
        }
        return cfgKeyList;
    }

    public static List<String> getCfgKeyList() {
        List<String> cfgKeyList = new ArrayList<>();
        for (SysCfgKeyEnums enums : values()) {
            cfgKeyList.add(enums.getCfgKey());
        }
        return cfgKeyList;
    }

    public static String getCfgDesc(String cfgKey) {
        for (SysCfgKeyEnums enums : values()) {
            if (enums.getCfgKey().equals(cfgKey)) {
                return enums.getCfgDesc();
            }
        }
        return null;
    }

    public static String getDefaultValue(String cfgKey) {
        for (SysCfgKeyEnums enums : values()) {
            if (enums.getCfgKey().equals(cfgKey)) {
                return enums.getDefaultValue();
            }
        }
        return null;
    }

    public static Integer getCfgType(String cfgKey) {
        for (SysCfgKeyEnums enums : values()) {
            if (enums.getCfgKey().equals(cfgKey)) {
                return enums.getCfgType();
            }
        }
        return null;
    }
}
